﻿using Md.Api.Model;
using Md.Api.Model.Manage.MdWebNavigation.Request;
using Md.Api.Service.Manage.MdWebNavigation;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 网站导航
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/md/webNavigation")]
public class MdWebNavigationController : ControllerBase
{
    /// <summary>
    /// 通过编号删除网站导航服务
    /// </summary>
    public DeleteMdWebNavigationByIdService deleteMdWebNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号删除网站导航
    /// </summary>
    /// <param name="navIds">导航编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{navIds}")]
    public async Task<ResponseMessageModel> DeleteMdWebNavigationById(string navIds, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteMdWebNavigationByIdModel();

        model.Ids = navIds;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteMdWebNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 添加网站导航服务
    /// </summary>
    public InsertMdWebNavigationService insertMdWebNavigationService { get; set; }
    /// <summary>
    /// 添加网站导航
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdWebNavigation([FromBody] RequestInsertMdWebNavigationModel model)
    {
        return await Task.Run(() => insertMdWebNavigationService.Execute(model));
    }

    /// <summary>
    /// 通过编号更新网站导航服务
    /// </summary>
    public UpdateMdWebNavigationByIdService updateMdWebNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号更新网站导航
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateMdWebNavigationById([FromBody] RequestUpdateMdWebNavigationByIdModel model)
    {
        return await Task.Run(() => updateMdWebNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取网站导航服务
    /// </summary>
    public GetMdWebNavigationByIdService getMdWebNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号获取网站导航
    /// </summary>
    /// <param name="navId">导航编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{navId}")]
    public async Task<ResponseMessageModel> GetMdWebNavigationById(long navId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdWebNavigationByIdModel();

        model.NavId = navId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdWebNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 获取网站导航列表服务
    /// </summary>
    public GetMdWebNavigationListService getMdWebNavigationListService { get; set; }
    /// <summary>
    /// 获取网站导航列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetMdWebNavigationList([FromBody] RequestGetMdWebNavigationListModel model)
    {
        return await Task.Run(() => getMdWebNavigationListService.Execute(model));
    }

    /// <summary>
    /// 分页获取网站导航列表服务
    /// </summary>
    public GetMdWebNavigationPageListService getMdWebNavigationPageListService { get; set; }
    /// <summary>
    /// 分页获取网站导航列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdWebNavigationPageList([FromBody] RequestGetMdWebNavigationPageListModel model)
    {
        return await Task.Run(() => getMdWebNavigationPageListService.Execute(model));
    }
}

